/*
 * Copyright 2017 hv0912
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.vimhe.ezimp2.handler;

import com.vimhe.ezimp2.config.bean.ColumnConfig;
import com.vimhe.ezimp2.handler.bean.CellData;
import com.vimhe.ezimp2.handler.validator.ErrorMessage;

/**
 * 数据验证器接口
 *
 * @author Vimhe
 */
public interface Validator {

    /**
     * 为验证器指定一个名称
     *
     * @return 验证器名称
     */
    String name();

    /**
     * 验证数据
     * <br>如果没有找到对应的验证器则返回“null”
     * <br>如果验证成功则返回“null”
     * <br>如果验证不成功则返回错误消息对象
     *
     * @param cellData     单元格数据对象
     * @param columnConfig 单元格配置对象
     * @return 验证不通过的错误信息
     */
    ErrorMessage validate(CellData cellData, ColumnConfig columnConfig);

}
